import java.util.Arrays;

public class Test4 {
    public static void my_sort(Comparable[] comparables){
        for (int i = 0; i <comparables.length - 1 ; i++) {
            for (int j = 0; j <comparables.length - i - 1 ; j++) {
                if(comparables[j].compareTo(comparables[j + 1]) > 0){
                    Comparable tmp = comparables[j];
                    comparables[j] = comparables[j + 1];
                    comparables[j + 1] = tmp;
                }
            }
        }
    }

    public static void main(String[] args){
        Test1.classroom[] classroom = new Test1.classroom[3];
        classroom[0] = new Test1.classroom(18,"小明");
        classroom[1] = new Test1.classroom(15,"小礼");
        classroom[2] = new Test1.classroom(21,"小花");
        my_sort(classroom);
        System.out.println(Arrays.toString(classroom));

        Test1.NameComparator nameComparator = new Test1.NameComparator();
        Test1.AgeComparator ageComparator = new Test1.AgeComparator();
        System.out.println(nameComparator.compare(classroom[0], classroom[1]));
        System.out.println(ageComparator.compare(classroom[1], classroom[2]));


    }
}
